package yz.com.javautil.astar;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

/**
 * @author Administrator
 */
@Data
@Setter
@Getter
public class AStarGrid {
    /**
     * 节点数组
     */
    private AStarNode[][] map;

    /**
     * 起点和终点
     */
    private AStarNode startAStarNode, endAStarNode;

    public AStarGrid() {
        map = new AStarNode[7][7];
        for (int i = 0; i < 7; i++) {
            for (int j = 0; j < 7; j++) {
                map[i][j] = new AStarNode(i, j, "o", true);
            }
        }
        for (int d = 0; d < 7; d++) {
            map[0][d].setValue("%");
            map[0][d].setReachable(false);
            map[d][0].setValue("%");
            map[d][0].setReachable(false);
            map[6][d].setValue("%");
            map[6][d].setReachable(false);
            map[d][6].setValue("%");
            map[d][6].setReachable(false);
        }
        map[3][1].setValue("A");
        startAStarNode = map[3][1];
        map[3][5].setValue("B");
        endAStarNode = map[3][5];
        for (int k = 1; k <= 3; k++) {
            map[k + 1][3].setValue("#");
            map[k + 1][3].setReachable(false);
        }
    }

    public void showMap() {
        for (int i = 0; i < 7; i++) {
            for (int j = 0; j < 7; j++) {
                System.out.print(map[i][j].getValue() + " ");
            }
            System.out.println("");
        }
    }

}
